@use 'var';
@use 'mixins';

.example {
  margin-bottom: 4rem;
  &__actions {
    display: flex;
    justify-content: flex-end;
    padding: 0.6rem 0;
  }

  &__action-btn {
    @include mixins.flex-center;
    border-radius: 50%;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    margin-left: 1.5rem;
    .material-icons {
      font-size: 1.2rem;
    }
    &--on {
      background-color: var.$border-light;
      .szh-app--theme-dark & {
        background-color: var.$border-dark;
      }
    }
    &--link {
      color: #007bff;
    }
  }

  &__demo {
    @include mixins.flex-center;
    background-color: white;
    padding: 1rem;
    border-radius: var.$border-radius-medium;
    @include mixins.border;
  }
}

.example__actions {
  .szh-menu {
    min-width: auto;
    padding: 0.625rem 1rem;
  }
}

.option-form {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  margin-right: -1.5rem;
  .options {
    flex: 1 1 10rem;
    @include mixins.border;
    border-radius: var.$border-radius-medium;
    margin: 0 1.5rem 1.5rem 0;
    position: relative;
    padding: 2rem 0 0 0;

    legend {
      box-sizing: border-box;
      color: inherit;
      background-color: var.$border-light;
      border-top-left-radius: var.$border-radius-medium;
      border-top-right-radius: var.$border-radius-medium;
      width: calc(100% + 2px);
      max-width: inherit;
      position: absolute;
      left: -1px;
      top: -1px;
      padding: 0.25rem 1rem;
      font-size: 1rem;
      white-space: nowrap;
    }

    label {
      margin: 0.75rem 1rem;
      display: block;
    }

    .szh-app--theme-dark & {
      border-color: var.$border-dark;
      legend {
        background-color: var.$btn-dark;
      }
    }
  }
}

[aria-labelledby='event-handling'] {
  .example__demo {
    height: 15rem;
    align-items: stretch;
    justify-content: space-around;

    .buttons {
      display: flex;
      flex-direction: column;
      justify-content: space-around;
    }

    .output {
      @include mixins.reset-list;
      font-size: 0.9rem;
      flex: 0 1 20rem;
      margin-left: 1rem;
      overflow-y: auto;
      border-radius: var.$border-radius-medium;
      @include mixins.border;
      @include mixins.scrollbar;

      .szh-app--theme-dark & {
        @include mixins.scrollbar-dark;
        border-color: var.$border-dark;
      }
    }
  }
}

[aria-labelledby='focusable-item'] {
  .example__demo input {
    max-width: 10rem;
  }
}

[aria-labelledby='menu-placement'] {
  .example__demo {
    flex-direction: column;
    padding: 1.5rem;

    .menus {
      display: flex;
      justify-content: space-around;
      align-self: stretch;
      gap: 0.5rem;
    }

    .alert-warning {
      margin-bottom: 1.5rem;
      .material-icons {
        position: relative;
        font-size: 1.5rem;
        top: 0.375rem;
      }
    }

    .szh-menu-button {
      flex: 0 1 6rem;
      min-width: auto;
    }
  }
}

[aria-labelledby='menu-overflow'] {
  .example__demo {
    .option-form {
      margin: 0 1rem -1rem 0;
      justify-content: center;
      .options {
        flex: 1 1 auto;
        margin: 0 1rem 1rem 0;
        max-width: 22rem;
      }

      @media (max-width: var.$bp-sm) {
        margin-right: 0;
      }
    }

    .szh-menu-button {
      white-space: nowrap;
      margin: 0 0.5rem;
    }

    .szh-menu {
      z-index: 201;
      input {
        max-width: 7rem;
      }
    }
  }
}

[aria-labelledby='bounding-box'] {
  .example__demo {
    display: block;
  }

  .scrollview {
    position: relative;
    height: 20rem;
    overflow: auto;
    margin-top: 0.75rem;
    border-radius: var.$border-radius-medium;
    @include mixins.border;
    @include mixins.scrollbar;
    .szh-app--theme-dark & {
      @include mixins.scrollbar-dark;
      border-color: var.$border-dark;
    }
  }

  .bounding-box {
    padding-bottom: 26rem;
    display: flex;
    justify-content: space-around;
    @media (max-width: var.$bp-sm) {
      display: block;
    }
  }

  .anchor {
    width: 4rem;
    height: 3.5rem;
    margin-top: 14rem;
    border-radius: var.$border-radius-medium;
    background-color: var.$btn-light;
    @include mixins.border('border', 2px, false);
    .szh-app--theme-dark & {
      border-color: var.$border-dark;
      background-color: var.$background-dark;
    }
    @media (max-width: var.$bp-sm) {
      &.left {
        margin-left: auto;
        margin-right: auto;
      }
      &.right {
        margin-left: 2rem;
      }
    }
  }

  label {
    user-select: none;
  }

  input[type='checkbox'] {
    appearance: checkbox;
    transform: scale(1.25);
    margin-right: 0.75rem;
  }
}

.bounding-box-menu {
  max-width: 7.5rem;
  min-width: auto;
  white-space: normal;
  text-align: center;
  padding: 0.625rem 0.5rem;
  &.portal {
    z-index: 201;
  }
}

[aria-labelledby='context-menu'] {
  .example__demo {
    min-height: 8rem;
    user-select: none;
  }
}
